<?php
namespace Retailer\Controller\Component;

use Cake\Controller\Component;
use Taobao\TopClient\Client;
use Taobao\TopClient\Request\WirelessShareTpwdQueryRequest;

/**
 * 淘宝处理
 *
 * @property \Retailer\Controller\Component\TaobaoComponent $client
 *
 */
class TaobaoComponent extends Component
{

    var $client;

    /**
     * Default configuration.
     *
     * @var array
     */
    protected $_defaultConfig = [];

    public function initialize(array $config)
    {
        parent::initialize($config);
        $this->client = new Client("23825453", "e53453a32e04de9a1fdb2b6f9b5150be");
        $this->client->format = "json";
    }

    /**
     * 获取产品信息
     * @param string $str
     * @return unknown|\Taobao\TopClient\ResultSet|mixed
     */
    public function getGoodsInfo($str)
    {
        $req = new WirelessShareTpwdQueryRequest();
        $req->setPasswordContent($str);
        $result = $this->client->execute($req);
        return $result;
    }
}
